export TTDIR=/usr/local/teamtools

yum -y install coreutils
rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum install -y --enablerepo=rpmforge-extras subversion mod_dav_svn
yum update -y --enablerepo=rpmforge-extras subversion mod_dav_svn

yum -y install perl-CPAN perl-YAML perl-XML-Parser gcc-c++ gd-devel mod_perl make perl-Net-SSLeay perl-IO-Socket-SSL

yes|cpan App::cpanminus

cpanm SVN::Hooks
cpanm SVN::Access
cpanm SVN::Access::Group
cpanm XML::Simple
cpanm CGI
cpanm DBI
cpanm DBD::SQLite
cpanm IO::String
cpanm URI::Escape
cpanm parent
cpanm Date::Calc
cpanm GD::Graph
cpanm Time::HiRes
cpanm Lucy
cpanm JSON
cpanm Log::Log4perl
cpanm Log::Dispatch::File
cpanm HTML::Template
cpanm Error
cpanm DateTime
cpanm Archive::Zip
cpanm MIME::Base64
cpanm Net::SMTP::TLS
cpanm Proc::Fork
cpanm File::Pid
cpanm Proc::Daemon
cpanm Forks::Super -f
cpanm Math::Round


mkdir -p /var/db/svn
mkdir -p /var/db/lucy
mkdir -p /var/db/sqlite
mkdir -p /var/log/teamtools
mkdir -p /etc/teamtools

svnadmin create /var/db/svn/repo01
cp ${TTDIR}/conf/httpd/* /etc/httpd/conf.d/
cp ${TTDIR}/conf/config.xml /etc/teamtools/

export PERL5LIB=${TTDIR}/lib

chmod 777 ${TTDIR}/bin/*
${TTDIR}/bin/createDepIndex.pl
${TTDIR}/bin/createIndex.pl
${TTDIR}/bin/createMailDB.pl
${TTDIR}/bin/createReviewDB.pl
${TTDIR}/bin/createStatsDB.pl

>/var/log/teamtools/messages

chown -R apache:apache /var/db/svn
chown -R apache:apache /var/db/lucy
chown -R apache:apache /var/db/sqlite
chown -R apache:apache /var/log/teamtools
chown -R apache:apache /etc/teamtools


yum -y install policycoreutils-python
chcon -R --type httpd_sys_content_t /var/db/svn
chcon -R --type httpd_sys_content_t /var/db/lucy
chcon -R --type httpd_sys_content_t /var/db/sqlite
chcon -R --type httpd_sys_content_t /var/log/teamtools
chcon -R --type httpd_sys_content_t /etc/teamtools
chcon -R --type httpd_sys_content_t /usr/local/teamtools
semanage fcontext -a --type httpd_sys_content_t '/var/db/svn(/*)?'
semanage fcontext -a --type httpd_sys_content_t '/var/db/lucy(/*)?'
semanage fcontext -a --type httpd_sys_content_t '/var/db/sqlite(/*)?'
semanage fcontext -a --type httpd_sys_content_t '/var/log/teamtools(/*)?'
semanage fcontext -a --type httpd_sys_content_t '/usr/local/teamtools(/*)?'

